<template>
  <el-card class="page-container">
    <div slot="header" class="page-header">
      <h2>系统参数配置</h2>
    </div>

    <el-form ref="form" :model="formData" label-width="120px">
      <el-form-item label="网站标题">
        <el-input v-model="formData.siteTitle" placeholder="请输入网站标题"></el-input>
      </el-form-item>
      <el-form-item label="每页显示条数">
        <el-input-number v-model="formData.pageSize" :min="10" :max="100" :step="10"></el-input-number>
      </el-form-item>
      <el-form-item label="缓存时间(分钟)">
        <el-input-number v-model="formData.cacheTime" :min="5" :max="120" :step="5"></el-input-number>
      </el-form-item>
      <el-form-item label="启用日志">
        <el-switch v-model="formData.enableLog"></el-switch>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="saveSettings">保存配置</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<script setup lang="ts">
import { ref, reactive } from 'vue';
import { ElMessage } from 'element-plus';

// 表单数据
const formData = reactive({
  siteTitle: 'Vue管理系统',
  pageSize: 20,
  cacheTime: 30,
  enableLog: true
});

// 表单引用
const form = ref(null);

// 保存配置
const saveSettings = () => {
  // 这里可以添加API调用保存到后端
  ElMessage.success('系统参数保存成功');
};

// 重置表单
const resetForm = () => {
  Object.assign(formData, {
    siteTitle: 'Vue管理系统',
    pageSize: 20,
    cacheTime: 30,
    enableLog: true
  });
};
</script>

<style scoped>
.page-container {
  margin: 20px;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>